package com.macro.mall.portal.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.portal.domain.ConfirmOrderResults;
import com.macro.mall.portal.service.SeckillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：尚志豪
 * @Package：com.macro.mall.portal.controller
 * @Project：mall-swarm-B
 * @name：SeckillController
 * @Date：2024/11/1 16:09
 */
@RestController
@RequestMapping("/seckill")
public class SeckillController {

    @Autowired
    private SeckillService seckillService;

    @PostMapping("/modifyStock")
    public CommonResult modifyStock(@RequestParam Long productId, int quantity){
       seckillService.modifyStock(productId,quantity);
       return  CommonResult.success("库存修改成功");
    }

    @PostMapping("/{productId}/{userId}")
    public ConfirmOrderResults seckill (@PathVariable Long productId,@PathVariable Long userId) {
        return seckillService.seckill(productId, userId);
    }
}
